package com.hqq.handler;

import com.hqq.util.ServiceTools;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyIncationHandler implements InvocationHandler {
    private Object target;

    public MyIncationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        if (method.getName().equals("doSome")){
            System.out.println("选择性输出");
        }
        Object res = null;//结果对象

        ServiceTools.doLog();
        res = method.invoke(target,args);
        ServiceTools.doTrans();


        return res;
    }
}
